<!doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<title>Validation</title>
	<link rel="stylesheet" type="text/css"  href="../../../../kissy-dpl/base/build/css/dpl-pkg.css" />
	<script src="../../../build/kissy.js" charset="utf-8"></script>
	
	<link rel="stylesheet" type="text/css"  href="doc.css" /> <script src="doc.js" charset="utf-8"></script>
	<script type="text/javascript" src="../../../tools/utils/syntaxhighlighter_3.0.83/scripts/shCore.js"></script>
<script type="text/javascript" src="../../../tools/utils/syntaxhighlighter_3.0.83/scripts/shBrushJScript.js"></script>
<link type="text/css" rel="stylesheet" href="../../../tools/utils/syntaxhighlighter_3.0.83/styles/shCoreDefault.css"/>
<script type="text/javascript">SyntaxHighlighter.all();</script>

	

	
</head>
<body>
 

<div id="viewdemo" class="doc">
	


<div class="note">
Field.showMessage方法可以控制显示提示信息
</div>

<form method="post">
<ul class="form">

	<li>
		<label class="hd">姓名：</label>
		<input class="text" type="text" id="f1"  data-valid="{length:[3,6,true,'长度在{0}至{1}之间']}"/>
	</li>
	
	<li>
		<button type="submit">提交</button> <button type="button" id="fire-ok">对了</button> <button type="button" id="fire-err">错了</button> 
	</li>
	
</ul>
</form>

<script>



	KISSY.use("validation",function(S,Validation){

			var form = S.query("form")[0],
			
				check = new Validation(form,{
					style: "under"
				}),
				
				field = check.get("f1");
				
				

			KISSY.Event.on("#fire-ok","click",function(){
				field.showMessage(true);
			});


			KISSY.Event.on("#fire-err","click",function(){
				field.showMessage(false,"可以自定义一个错误信息");
			});
			
			KISSY.Event.on(form,"submit",function(){
				check.isValid();
				return false;
			});
		
	});

</script>



</div>








</body>
</html>













